{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Collecting mlflow\n",
      "\u001b[?25l  Downloading https://files.pythonhosted.org/packages/aa/2d/7fa1f6e310ded489d943ea20cd7977a9867cb8d81b526d9c9460ce4a5b39/mlflow-1.11.0-py3-none-any.whl (13.9MB)\n",
      "\u001b[K    100% |████████████████████████████████| 13.9MB 1.6MB/s ta 0:00:011   28% |█████████                       | 3.9MB 8.5MB/s eta 0:00:02    37% |███████████▉                    | 5.1MB 10.2MB/s eta 0:00:01\n",
      "\u001b[?25hRequirement already satisfied: protobuf>=3.6.0 in /Users/ben/anaconda3/lib/python3.6/site-packages (from mlflow) (3.12.2)\n",
      "Requirement already satisfied: sqlalchemy<=1.3.13 in /Users/ben/anaconda3/lib/python3.6/site-packages (from mlflow) (1.2.15)\n",
      "Requirement already satisfied: python-dateutil in /Users/ben/anaconda3/lib/python3.6/site-packages (from mlflow) (2.7.5)\n",
      "Requirement already satisfied: Flask in /Users/ben/anaconda3/lib/python3.6/site-packages (from mlflow) (1.0.2)\n",
      "Collecting querystring-parser (from mlflow)\n",
      "  Downloading https://files.pythonhosted.org/packages/4a/fa/f54f5662e0eababf0c49e92fd94bf178888562c0e7b677c8941bbbcd1bd6/querystring_parser-1.2.4.tar.gz\n",
      "Requirement already satisfied: pandas in /Users/ben/anaconda3/lib/python3.6/site-packages (from mlflow) (1.1.0)\n",
      "Requirement already satisfied: numpy in /Users/ben/anaconda3/lib/python3.6/site-packages (from mlflow) (1.19.1)\n",
      "Requirement already satisfied: click>=7.0 in /Users/ben/anaconda3/lib/python3.6/site-packages (from mlflow) (7.0)\n",
      "Requirement already satisfied: cloudpickle in /Users/ben/anaconda3/lib/python3.6/site-packages (from mlflow) (1.3.0)\n",
      "Requirement already satisfied: requests>=2.17.3 in /Users/ben/anaconda3/lib/python3.6/site-packages (from mlflow) (2.24.0)\n",
      "Collecting sqlparse (from mlflow)\n",
      "\u001b[?25l  Downloading https://files.pythonhosted.org/packages/85/ee/6e821932f413a5c4b76be9c5936e313e4fc626b33f16e027866e1d60f588/sqlparse-0.3.1-py2.py3-none-any.whl (40kB)\n",
      "\u001b[K    100% |████████████████████████████████| 40kB 4.5MB/s ta 0:00:01\n",
      "\u001b[?25hCollecting databricks-cli>=0.8.7 (from mlflow)\n",
      "\u001b[?25l  Downloading https://files.pythonhosted.org/packages/1e/57/5c2d6b83cb8753d12f548e89f91037632baa8289677c1b2ab2adf14bf6b2/databricks-cli-0.11.0.tar.gz (49kB)\n",
      "\u001b[K    100% |████████████████████████████████| 51kB 9.2MB/s eta 0:00:01\n",
      "\u001b[?25hCollecting docker>=4.0.0 (from mlflow)\n",
      "\u001b[?25l  Downloading https://files.pythonhosted.org/packages/9e/8c/8d42dbd83679483db207535f4fb02dc84325fa78b290f057694b057fcd21/docker-4.3.1-py2.py3-none-any.whl (145kB)\n",
      "\u001b[K    100% |████████████████████████████████| 153kB 25.3MB/s ta 0:00:01\n",
      "\u001b[?25hCollecting gitpython>=2.1.0 (from mlflow)\n",
      "\u001b[?25l  Downloading https://files.pythonhosted.org/packages/f9/1e/a45320cab182bf1c8656107b3d4c042e659742822fc6bff150d769a984dd/GitPython-3.1.7-py3-none-any.whl (158kB)\n",
      "\u001b[K    100% |████████████████████████████████| 163kB 12.0MB/s ta 0:00:01\n",
      "\u001b[?25hRequirement already satisfied: entrypoints in /Users/ben/anaconda3/lib/python3.6/site-packages (from mlflow) (0.3)\n",
      "Collecting alembic<=1.4.1 (from mlflow)\n",
      "\u001b[?25l  Downloading https://files.pythonhosted.org/packages/e0/e9/359dbb77c35c419df0aedeb1d53e71e7e3f438ff64a8fdb048c907404de3/alembic-1.4.1.tar.gz (1.1MB)\n",
      "\u001b[K    100% |████████████████████████████████| 1.1MB 6.2MB/s ta 0:00:011 3% |█▏                              | 40kB 6.2MB/s eta 0:00:01\n",
      "\u001b[?25hRequirement already satisfied: six>=1.10.0 in /Users/ben/anaconda3/lib/python3.6/site-packages (from mlflow) (1.15.0)\n",
      "Collecting gunicorn; platform_system != \"Windows\" (from mlflow)\n",
      "\u001b[?25l  Downloading https://files.pythonhosted.org/packages/69/ca/926f7cd3a2014b16870086b2d0fdc84a9e49473c68a8dff8b57f7c156f43/gunicorn-20.0.4-py2.py3-none-any.whl (77kB)\n",
      "\u001b[K    100% |████████████████████████████████| 81kB 1.7MB/s ta 0:00:01\n",
      "\u001b[?25hCollecting prometheus-flask-exporter (from mlflow)\n",
      "  Downloading https://files.pythonhosted.org/packages/01/d8/ddc1e7397cd0e8503eb09399ee1a650ac9d9041ac39da78d0d426d8d85af/prometheus_flask_exporter-0.16.4.tar.gz\n",
      "Collecting azure-storage-blob>=12.0 (from mlflow)\n",
      "\u001b[?25l  Downloading https://files.pythonhosted.org/packages/60/dc/3c25aeab827266c019e13abc07f31b5f47d93f1b8548a417c81c89c9d021/azure_storage_blob-12.4.0-py2.py3-none-any.whl (326kB)\n",
      "\u001b[K    100% |████████████████████████████████| 327kB 6.0MB/s ta 0:00:011\n",
      "\u001b[?25hRequirement already satisfied: pyyaml in /Users/ben/anaconda3/lib/python3.6/site-packages (from mlflow) (3.13)\n",
      "Collecting gorilla (from mlflow)\n",
      "  Downloading https://files.pythonhosted.org/packages/e3/56/5a683944cbfc77e429c6f03c636ca50504a785f60ffae91ddd7f5f7bb520/gorilla-0.3.0-py2.py3-none-any.whl\n",
      "Requirement already satisfied: setuptools in /Users/ben/anaconda3/lib/python3.6/site-packages (from protobuf>=3.6.0->mlflow) (49.2.1)\n",
      "Requirement already satisfied: Werkzeug>=0.14 in /Users/ben/anaconda3/lib/python3.6/site-packages (from Flask->mlflow) (0.14.1)\n",
      "Requirement already satisfied: Jinja2>=2.10 in /Users/ben/anaconda3/lib/python3.6/site-packages (from Flask->mlflow) (2.11.2)\n",
      "Requirement already satisfied: itsdangerous>=0.24 in /Users/ben/anaconda3/lib/python3.6/site-packages (from Flask->mlflow) (1.1.0)\n",
      "Requirement already satisfied: pytz>=2017.2 in /Users/ben/anaconda3/lib/python3.6/site-packages (from pandas->mlflow) (2018.7)\n",
      "Requirement already satisfied: chardet<4,>=3.0.2 in /Users/ben/anaconda3/lib/python3.6/site-packages (from requests>=2.17.3->mlflow) (3.0.4)\n",
      "Requirement already satisfied: certifi>=2017.4.17 in /Users/ben/anaconda3/lib/python3.6/site-packages (from requests>=2.17.3->mlflow) (2020.6.20)\n",
      "Requirement already satisfied: idna<3,>=2.5 in /Users/ben/anaconda3/lib/python3.6/site-packages (from requests>=2.17.3->mlflow) (2.10)\n",
      "Requirement already satisfied: urllib3!=1.25.0,!=1.25.1,<1.26,>=1.21.1 in /Users/ben/anaconda3/lib/python3.6/site-packages (from requests>=2.17.3->mlflow) (1.25.10)\n",
      "Requirement already satisfied: tabulate>=0.7.7 in /Users/ben/anaconda3/lib/python3.6/site-packages (from databricks-cli>=0.8.7->mlflow) (0.8.6)\n",
      "Requirement already satisfied: websocket-client>=0.32.0 in /Users/ben/anaconda3/lib/python3.6/site-packages (from docker>=4.0.0->mlflow) (0.54.0)\n",
      "Collecting gitdb<5,>=4.0.1 (from gitpython>=2.1.0->mlflow)\n",
      "\u001b[?25l  Downloading https://files.pythonhosted.org/packages/48/11/d1800bca0a3bae820b84b7d813ad1eff15a48a64caea9c823fc8c1b119e8/gitdb-4.0.5-py3-none-any.whl (63kB)\n",
      "\u001b[K    100% |████████████████████████████████| 71kB 8.3MB/s ta 0:00:011\n",
      "\u001b[?25hRequirement already satisfied: Mako in /Users/ben/anaconda3/lib/python3.6/site-packages (from alembic<=1.4.1->mlflow) (1.0.7)\n",
      "Collecting python-editor>=0.3 (from alembic<=1.4.1->mlflow)\n",
      "  Downloading https://files.pythonhosted.org/packages/c6/d3/201fc3abe391bbae6606e6f1d598c15d367033332bd54352b12f35513717/python_editor-1.0.4-py3-none-any.whl\n",
      "Requirement already satisfied: prometheus_client in /Users/ben/anaconda3/lib/python3.6/site-packages (from prometheus-flask-exporter->mlflow) (0.5.0)\n",
      "Collecting msrest>=0.6.10 (from azure-storage-blob>=12.0->mlflow)\n",
      "\u001b[?25l  Downloading https://files.pythonhosted.org/packages/d9/ed/8e1b75721ad983c1672cd968ad3ae374d2e94767edff6f0b72a15dfde933/msrest-0.6.18-py2.py3-none-any.whl (84kB)\n",
      "\u001b[K    100% |████████████████████████████████| 92kB 7.9MB/s ta 0:00:011\n",
      "\u001b[?25hCollecting azure-core<2.0.0,>=1.6.0 (from azure-storage-blob>=12.0->mlflow)\n",
      "\u001b[?25l  Downloading https://files.pythonhosted.org/packages/5b/e3/acb0c45c0b7afa33eca9fadb47f32cbfb95161e3719fcbe953d689b881bc/azure_core-1.8.0-py2.py3-none-any.whl (121kB)\n",
      "\u001b[K    100% |████████████████████████████████| 122kB 8.6MB/s eta 0:00:01\n",
      "\u001b[?25hRequirement already satisfied: cryptography>=2.1.4 in /Users/ben/anaconda3/lib/python3.6/site-packages (from azure-storage-blob>=12.0->mlflow) (2.6.1)\n",
      "Requirement already satisfied: MarkupSafe>=0.23 in /Users/ben/anaconda3/lib/python3.6/site-packages (from Jinja2>=2.10->Flask->mlflow) (1.1.0)\n",
      "Collecting smmap<4,>=3.0.1 (from gitdb<5,>=4.0.1->gitpython>=2.1.0->mlflow)\n",
      "  Downloading https://files.pythonhosted.org/packages/b0/9a/4d409a6234eb940e6a78dfdfc66156e7522262f5f2fecca07dc55915952d/smmap-3.0.4-py2.py3-none-any.whl\n",
      "Collecting isodate>=0.6.0 (from msrest>=0.6.10->azure-storage-blob>=12.0->mlflow)\n",
      "\u001b[?25l  Downloading https://files.pythonhosted.org/packages/9b/9f/b36f7774ff5ea8e428fdcfc4bb332c39ee5b9362ddd3d40d9516a55221b2/isodate-0.6.0-py2.py3-none-any.whl (45kB)\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\u001b[K    100% |████████████████████████████████| 51kB 8.8MB/s eta 0:00:01\n",
      "\u001b[?25hRequirement already satisfied: requests-oauthlib>=0.5.0 in /Users/ben/anaconda3/lib/python3.6/site-packages (from msrest>=0.6.10->azure-storage-blob>=12.0->mlflow) (1.0.0)\n",
      "Requirement already satisfied: asn1crypto>=0.21.0 in /Users/ben/anaconda3/lib/python3.6/site-packages (from cryptography>=2.1.4->azure-storage-blob>=12.0->mlflow) (0.24.0)\n",
      "Requirement already satisfied: cffi!=1.11.3,>=1.8 in /Users/ben/anaconda3/lib/python3.6/site-packages (from cryptography>=2.1.4->azure-storage-blob>=12.0->mlflow) (1.14.1)\n",
      "Requirement already satisfied: oauthlib>=0.6.2 in /Users/ben/anaconda3/lib/python3.6/site-packages (from requests-oauthlib>=0.5.0->msrest>=0.6.10->azure-storage-blob>=12.0->mlflow) (2.1.0)\n",
      "Requirement already satisfied: pycparser in /Users/ben/anaconda3/lib/python3.6/site-packages (from cffi!=1.11.3,>=1.8->cryptography>=2.1.4->azure-storage-blob>=12.0->mlflow) (2.20)\n",
      "Building wheels for collected packages: querystring-parser, databricks-cli, alembic, prometheus-flask-exporter\n",
      "  Running setup.py bdist_wheel for querystring-parser ... \u001b[?25ldone\n",
      "\u001b[?25h  Stored in directory: /Users/ben/Library/Caches/pip/wheels/1e/41/34/23ebf5d1089a9aed847951e0ee375426eb4ad0a7079d88d41e\n",
      "  Running setup.py bdist_wheel for databricks-cli ... \u001b[?25ldone\n",
      "\u001b[?25h  Stored in directory: /Users/ben/Library/Caches/pip/wheels/63/d0/4f/3deeca1f4c47a6aca7c2c6a6e2bf272391565dc86a7718a59b\n",
      "  Running setup.py bdist_wheel for alembic ... \u001b[?25ldone\n",
      "\u001b[?25h  Stored in directory: /Users/ben/Library/Caches/pip/wheels/84/07/f7/12f7370ca47a66030c2edeedcc23dec26ea0ac22dcb4c4a0f3\n",
      "  Running setup.py bdist_wheel for prometheus-flask-exporter ... \u001b[?25ldone\n",
      "\u001b[?25h  Stored in directory: /Users/ben/Library/Caches/pip/wheels/f0/ba/c4/62b4809cae9e7823ae296909e887c1b60eade9415ca4a286c2\n",
      "Successfully built querystring-parser databricks-cli alembic prometheus-flask-exporter\n",
      "Installing collected packages: querystring-parser, sqlparse, databricks-cli, docker, smmap, gitdb, gitpython, python-editor, alembic, gunicorn, prometheus-flask-exporter, isodate, msrest, azure-core, azure-storage-blob, gorilla, mlflow\n",
      "Successfully installed alembic-1.4.1 azure-core-1.8.0 azure-storage-blob-12.4.0 databricks-cli-0.11.0 docker-4.3.1 gitdb-4.0.5 gitpython-3.1.7 gorilla-0.3.0 gunicorn-20.0.4 isodate-0.6.0 mlflow-1.11.0 msrest-0.6.18 prometheus-flask-exporter-0.16.4 python-editor-1.0.4 querystring-parser-1.2.4 smmap-3.0.4 sqlparse-0.3.1\n"
     ]
    }
   ],
   "source": [
    "!pip install mlflow"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# this is adapted from https://github.com/mlflow/mlflow/blob/master/examples/sklearn_elasticnet_wine/train.ipynb"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "import numpy as np\n",
    "from sklearn.model_selection import train_test_split\n",
    "\n",
    "csv_url =\\\n",
    "    'http://archive.ics.uci.edu/ml/machine-' \\\n",
    "    'learning-databases/wine-quality/winequality-red.csv'\n",
    "data = pd.read_csv(csv_url, sep=';')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>fixed acidity</th>\n",
       "      <th>volatile acidity</th>\n",
       "      <th>citric acid</th>\n",
       "      <th>residual sugar</th>\n",
       "      <th>chlorides</th>\n",
       "      <th>free sulfur dioxide</th>\n",
       "      <th>total sulfur dioxide</th>\n",
       "      <th>density</th>\n",
       "      <th>pH</th>\n",
       "      <th>sulphates</th>\n",
       "      <th>alcohol</th>\n",
       "      <th>quality</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>7.4</td>\n",
       "      <td>0.70</td>\n",
       "      <td>0.00</td>\n",
       "      <td>1.9</td>\n",
       "      <td>0.076</td>\n",
       "      <td>11.0</td>\n",
       "      <td>34.0</td>\n",
       "      <td>0.9978</td>\n",
       "      <td>3.51</td>\n",
       "      <td>0.56</td>\n",
       "      <td>9.4</td>\n",
       "      <td>5</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>7.8</td>\n",
       "      <td>0.88</td>\n",
       "      <td>0.00</td>\n",
       "      <td>2.6</td>\n",
       "      <td>0.098</td>\n",
       "      <td>25.0</td>\n",
       "      <td>67.0</td>\n",
       "      <td>0.9968</td>\n",
       "      <td>3.20</td>\n",
       "      <td>0.68</td>\n",
       "      <td>9.8</td>\n",
       "      <td>5</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>7.8</td>\n",
       "      <td>0.76</td>\n",
       "      <td>0.04</td>\n",
       "      <td>2.3</td>\n",
       "      <td>0.092</td>\n",
       "      <td>15.0</td>\n",
       "      <td>54.0</td>\n",
       "      <td>0.9970</td>\n",
       "      <td>3.26</td>\n",
       "      <td>0.65</td>\n",
       "      <td>9.8</td>\n",
       "      <td>5</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>11.2</td>\n",
       "      <td>0.28</td>\n",
       "      <td>0.56</td>\n",
       "      <td>1.9</td>\n",
       "      <td>0.075</td>\n",
       "      <td>17.0</td>\n",
       "      <td>60.0</td>\n",
       "      <td>0.9980</td>\n",
       "      <td>3.16</td>\n",
       "      <td>0.58</td>\n",
       "      <td>9.8</td>\n",
       "      <td>6</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>7.4</td>\n",
       "      <td>0.70</td>\n",
       "      <td>0.00</td>\n",
       "      <td>1.9</td>\n",
       "      <td>0.076</td>\n",
       "      <td>11.0</td>\n",
       "      <td>34.0</td>\n",
       "      <td>0.9978</td>\n",
       "      <td>3.51</td>\n",
       "      <td>0.56</td>\n",
       "      <td>9.4</td>\n",
       "      <td>5</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   fixed acidity  volatile acidity  citric acid  residual sugar  chlorides  \\\n",
       "0            7.4              0.70         0.00             1.9      0.076   \n",
       "1            7.8              0.88         0.00             2.6      0.098   \n",
       "2            7.8              0.76         0.04             2.3      0.092   \n",
       "3           11.2              0.28         0.56             1.9      0.075   \n",
       "4            7.4              0.70         0.00             1.9      0.076   \n",
       "\n",
       "   free sulfur dioxide  total sulfur dioxide  density    pH  sulphates  \\\n",
       "0                 11.0                  34.0   0.9978  3.51       0.56   \n",
       "1                 25.0                  67.0   0.9968  3.20       0.68   \n",
       "2                 15.0                  54.0   0.9970  3.26       0.65   \n",
       "3                 17.0                  60.0   0.9980  3.16       0.58   \n",
       "4                 11.0                  34.0   0.9978  3.51       0.56   \n",
       "\n",
       "   alcohol  quality  \n",
       "0      9.4        5  \n",
       "1      9.8        5  \n",
       "2      9.8        5  \n",
       "3      9.8        6  \n",
       "4      9.4        5  "
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Split the data into training and test sets. (0.75, 0.25) split.\n",
    "# The predicted column is \"quality\" which is a scalar from [3, 9]\n",
    "train_x, test_x, train_y, test_y = train_test_split(\n",
    "    data.drop(['quality'], axis=1),\n",
    "    data['quality']\n",
    ")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [],
   "source": [
    "from sklearn.metrics import mean_squared_error, mean_absolute_error, r2_score\n",
    "\n",
    "def eval_metrics(actual, pred):\n",
    "    rmse = np.sqrt(mean_squared_error(actual, pred))\n",
    "    mae = mean_absolute_error(actual, pred)\n",
    "    r2 = r2_score(actual, pred)\n",
    "    return rmse, mae, r2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [],
   "source": [
    "import mlflow\n",
    "\n",
    "mlflow.set_tracking_uri('http://0.0.0.0:5000')  # set to your server URI\n",
    "mlflow.set_experiment('/wine')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {},
   "outputs": [],
   "source": [
    "from sklearn.linear_model import ElasticNet\n",
    "import mlflow.sklearn\n",
    "\n",
    "np.random.seed(40)\n",
    "\n",
    "def train(alpha=0.5, l1_ratio=0.5):\n",
    "    with mlflow.start_run():\n",
    "        lr = ElasticNet(alpha=alpha, l1_ratio=l1_ratio, random_state=42)\n",
    "        lr.fit(train_x, train_y)\n",
    "        predicted = lr.predict(test_x)\n",
    "        rmse, mae, r2 = eval_metrics(test_y, predicted)\n",
    "\n",
    "        model_name = lr.__class__.__name__\n",
    "        print('{} (alpha={}, l1_ratio={}):'.format(\n",
    "            model_name, alpha, l1_ratio\n",
    "        ))\n",
    "        print(' RMSE: %s' % rmse)\n",
    "        print(' MAE: %s' % mae)\n",
    "        print(' R2: %s' % r2)\n",
    "\n",
    "        mlflow.log_params({key: value for key, value in lr.get_params().items()})\n",
    "        mlflow.log_metric('rmse', rmse)\n",
    "        mlflow.log_metric('r2', r2)\n",
    "        mlflow.log_metric('mae', mae)\n",
    "        mlflow.sklearn.log_model(lr, model_name)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "ElasticNet (alpha=0.5, l1_ratio=0.5):\n",
      "  RMSE: 0.7325693777577805\n",
      "  MAE: 0.5895721434715478\n",
      "  R2: 0.12163690293641838\n"
     ]
    }
   ],
   "source": [
    "train(0.5, 0.5)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "ElasticNet (alpha=0.1, l1_ratio=0.5):\n",
      "  RMSE: 0.6832521710295818\n",
      "  MAE: 0.5350826216023779\n",
      "  R2: 0.23592040719074103\n"
     ]
    }
   ],
   "source": [
    "train(0.1, 0.5)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "ElasticNet (alpha=0.8, l1_ratio=0.5):\n",
      "  RMSE: 0.7713038517785624\n",
      "  MAE: 0.6344212065633348\n",
      "  R2: 0.026294640912563283\n"
     ]
    }
   ],
   "source": [
    "train(0.8, 0.5)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "ElasticNet (alpha=0.1, l1_ratio=0.2):\n",
      "  RMSE: 0.6740753299699419\n",
      "  MAE: 0.5276949437873688\n",
      "  R2: 0.25630745861273185\n"
     ]
    }
   ],
   "source": [
    "train(0.1, 0.2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "ElasticNet (alpha=0.1, l1_ratio=0.3):\n",
      "  RMSE: 0.6781545799635063\n",
      "  MAE: 0.5308991080094628\n",
      "  R2: 0.2472791287278865\n"
     ]
    }
   ],
   "source": [
    "train(0.1, 0.3)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "ElasticNet (alpha=0.2, l1_ratio=0.2):\n",
      "  RMSE: 0.6844856006568806\n",
      "  MAE: 0.5375117838920673\n",
      "  R2: 0.2331592331820277\n"
     ]
    }
   ],
   "source": [
    "train(0.2, 0.2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "ElasticNet (alpha=0.1, l1_ratio=0.1):\n",
      "  RMSE: 0.6690250543541869\n",
      "  MAE: 0.5236546308642179\n",
      "  R2: 0.2674094302489908\n"
     ]
    }
   ],
   "source": [
    "train(0.1, 0.1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "ElasticNet (alpha=0.05, l1_ratio=0.05):\n",
      "  RMSE: 0.6586566565045078\n",
      "  MAE: 0.5152309297379374\n",
      "  R2: 0.28994051940308996\n"
     ]
    }
   ],
   "source": [
    "train(0.05, 0.05)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.11"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
